﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using SharedLib.BasicServices.MessageFramework;

namespace Tracy.Messages
{
    public class TaskMessage<TData, TResult> : TaskMessage
    {
        Type _handler;
        public override Type Handler
        {
            get { return _handler; }
        }

        public TaskMessage(object sender, Type handler, MessageCallback callback)
            : base(sender, handler, callback)
        {
            _handler = handler;
        }

        public TaskMessage(object sender, Type handler, TData data, MessageCallback callback)
            : base(sender, handler, data, callback)
        {
            _handler = handler;
        }

        public TData GenericData
        {
            get 
            { 
                if(Data !=null && Data is TData)
                    return (TData)Data;
                return default(TData);
            }
        }

        public TResult GenericResult
        {
            get 
            {
                if(Result != null && Result is TResult)
                    return (TResult)Result;
                return default(TResult);
            }
            set
            {
                Result = value;
            }
        }
    }
}
